﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using LSUtility;

namespace LSEntity
{
    public class MemberClassEntity
    {
        public int ClassId { get; set; }
        public string ClassName { get; set; }
        public int SchoolId { get; set; }
        public int GradeId { get; set; }
    }

    public class MemberEntity
    {
        public MemberEntity()
        {
            MemberExtend = new MemberExtendEntity();
            ClassList = new List<MemberClassEntity>();
        }

        public int AccountId { get; set; }
        public string Account { get; set; }
        public string RealName { get; set; }
        public MemberTypeEntity Type { get; set; }
        public DateTime LastLoginTM { get; set; }
        public MemberExternalType MemberLoginType { get; set; }
        public MemberExtendEntity MemberExtend { get; set; }
        public List<MemberClassEntity> ClassList { get; set; }

        public DateTime Born { get; set; }
        public string Mobile { get; set; }
        public short Gender { get; set; }
        public string Email { get; set; }

        public MemberClassEntity MyClass
        {
            get { return ClassList.FirstOrDefault() ?? new MemberClassEntity(); }
        }

        public override string ToString()
        {
            switch (MemberLoginType)
            {
                case MemberExternalType.Local:
                    {

                        return String.IsNullOrEmpty(RealName) ? Account : RealName;
                    }
                default:
                    {
                        return RealName;
                    }
            }
        }
    }

    public class MemberExtendEntity
    {
        public int AccountId { get; set; }
        public string Head { get; set; }
        public MemberExtendType Type { get; set; }
        public short Approved { get; set; }
        public string ParentPassword { get; set; }
        public int Curriculum { get; set; }
        public int Grade { get; set; }
        public int Module { get; set; }
        public int Unit { get; set; }
        public int UnitModifyTM { get; set; }
        public int SchoolId { get; set; }
        public DateTime SysemMessageTime { get; set; }

        public override string ToString()
        {
            return String.Format("AccountId:{0},Type:{1}", AccountId.ToString(CultureInfo.InvariantCulture), Type);
        }
    }

    [Flags]
    public enum MemberExtendType
    {
        EngPrimaryTeacher = 1,
        EngMiddleTeacher = 2,
        EngHighTeacher = 4,
        MathPrimaryTeacher = 8,
        MathMiddleTeacher = 16,
        MathHighTeacher = 32,
    }

    /// <summary>
    /// 帐号外接类型
    /// </summary>
    public enum MemberExternalType
    {
        /// <summary>
        /// 本地帐号
        /// </summary>
        [EnumOrder(IsHide = true)]
        Local = 0,

        /// <summary>
        /// 三源帐号
        /// </summary>
        [EnumOrder(IsHide = true)]
        Sanyan = 1,

        /// <summary>
        /// 91网龙平台
        /// </summary>
        [EnumOrder(IsHide = true)]
        OAP = 2,

        /// <summary>
        /// 开心网
        /// </summary>
        [Description("开心网")]
        KaiXin = 3,

        /// <summary>
        /// QQ登录
        /// </summary>
        [Description("QQ帐号")]
        QQ = 4,

        /// <summary>
        /// 139邮箱登录
        /// </summary>
        [Description("139邮箱")]
        Mail139 = 5,

        /// <summary>
        /// 新闻微博用户
        /// </summary>
        //[Description("新浪微博")]
        [EnumOrder(IsHide = true)]
        Sina = 6,

        /// <summary>
        /// 人人网登录
        /// </summary>
        [Description("人人网")]
        [EnumOrder(IsHide = true)]
        RenRen = 7,

        /// <summary>
        /// 淘师湾
        /// </summary>
        [Description("淘师湾")]
        [EnumOrder(IsHide = false)]
        TSW = 8,
    }

    public enum MemberTypeEntity
    {
        Student = 1,
        Parents = 2,
        OACTeacher = 3,
        Teacher = 4,
    }
}
